<template>
    <!-- 我们不知道什么时候能拿到max 异步操作,所以需要监听watch -->
    <div class="mui-numbox" data-numbox-min='1'>
        <button class="mui-btn mui-btn-numbox-minus" type="button">-</button>
        <input id="test" class="mui-input-numbox" type="number" :value="initcount" @change="countChanged" ref="numbox"/>
        <button class="mui-btn mui-btn-numbox-plus" type="button">+</button>
    </div>
</template>

<script>
import mui from "../../lib/js/mui.min.js";
export default {
  mounted() {
    //初始化数字框
    mui(".mui-numbox").numbox();
    // console.log(this.initcount)
  },
  methods: {
    countChanged() {
      // console.log(this.$refs.numbox.value)
      //每当数量改变,则把新的id和数量传过去
      this.$store.commit("updateinfo", {
        id: this.goodsid,
        count: this.$refs.numbox.value
      });
      // console.log({id:this.goodsid,count:this.$refs.numbox.value})
    }
  },
  props: ["initcount", "goodsid"]
};
</script>

<style lang="sass" scoped>
.mui-numbox{
            height: 30px;
        }
</style>
